<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
		<div id="page-wrapper">
			<div class="row">
                <div class="col-lg-12">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">项目</label>
                        <div class="col-sm-4">
                        <select class="form-control" id="semProject">
                        </select>
                        </div>
                        <label class="col-sm-2 control-label">当前节点</label>
                        <div class="col-sm-4">
                        <select class="form-control" id="semCurrentNode">
                        	<option value="commit">故障提交</option>
                        	<option value="fix">故障修复</option>
                        	<option value="test">测试验证</option>
                        	<option value="end">结束</option>
                        </select>
                        </div>
                    </div>
                </div>
            </div>
			<div class="row">
                <div class="col-lg-12">
                    <div id="bugCharts" style="width: 600px;height:400px;"></div>
                </div>
            </div>
            <script>
         		// 初始化ECharts控件
				var bugCharts = echarts.init(document.getElementById('bugCharts'));
            	function showChart () {
            		$.get('${pageContext.request.contextPath}/sem/bug/charts?projectId=' + $('#semProject').val() + '&currentNode=' + $('#semCurrentNode').val()).done(function (eChartsData) {
						// 设置图表的数据
						bugCharts.setOption({
					        title: {
					            text: '故障版本分布图'
					        },
					        tooltip: {},
					        legend: {
					            data:eChartsData.legends
					        },
					        xAxis: {
					            data: eChartsData.xAxis
					        },
					        yAxis: {},
					        series: eChartsData.series
					    });
					});
            	}
				// 判断select下是否已经加载option，如果没有，则发送ajax请求，加载option
				if ($('#semProject option').length == 0) {
					$('#semProject').load ('${pageContext.request.contextPath}/sem/bug/projects', function () {
						showChart();
					});
				}
				// 设置下拉框的change：
				$('#page-wrapper select').change (function () {
					showChart();
				});
			</script>
        </div>

